{
    //变量声明时的联合类型
    let a:(number|string) =1
    a='1'

    //函数接受参数可以时数组和字符串    
        function fn(x:(number|string)){

        }
        fn(1)
        fn('2')

        //定义一个函数 得到传入参数的长度
        //用类型断言  将x 就当作string
        function fn0(x:(number|string)){
            (x as string).length?(x as string).length:x.toString().length
        }
        fn0(123)
        fn0('456')
        
}